// const app = getApp();
// Component({
//   options: {
//     addGlobalClass: true,
//   },
//   data: {
//     StatusBar: app.globalData.StatusBar,
//     CustomBar: app.globalData.CustomBar,
//     list: [{
//         title: '盯防任务',
//         img: 'https://lineinspection.oss-cn-chengdu.aliyuncs.com/hiddentaskbg.png',
//         url: '/hiddentask/monitoringlist'
//     },
//       {
//         title: '任务指派',
//         img: 'https://lineinspection.oss-cn-chengdu.aliyuncs.com/dispatchbg.png',
//         url: '/animation/animation'
//       },
//       {
//         title: '任务判定',
//         img: 'https://lineinspection.oss-cn-chengdu.aliyuncs.com/checkbg.png',
//         url: '/drawer/drawer'
//       }
//     ]
//   },
//   methods: {
//     toChild(e) {
//       console.log(e)
//       console.log('/pages/monitoring/' + e.currentTarget.dataset.url)
//       wx.navigateTo({
//         url: '/pages/monitoring/' + e.currentTarget.dataset.url
//       })
//     },

//     toChild1(){
//       wx.navigateTo({
//         url: '/pages/monitoring/hiddentask/monitoringlist'
//       })
//     }

//   }
// });

Page({

  /**
   * 页面的初始数据
   */
  data: {
    role: '',
    list: [{
      title: '盯防任务',
      img: 'https://lineinspection.oss-cn-chengdu.aliyuncs.com/hiddentaskbg.png',
      url: '/hiddentask/monitoringlist'
  },
    {
      title: '任务指派',
      img: 'https://lineinspection.oss-cn-chengdu.aliyuncs.com/dispatchbg.png',
      url: '/animation/animation'
    },
    {
      title: '任务判定',
      img: 'https://lineinspection.oss-cn-chengdu.aliyuncs.com/checkbg.png',
      url: '/drawer/drawer'
    }
  ]
  },
  onLoad(options) {
    this.initMeun()
  },
  
  initMeun() {
    const userInfoDto1 = wx.getStorageSync('userInfoDto')
    console.log(userInfoDto1)
    console.log(userInfoDto1.roleCodeList)
    if(Object.keys(userInfoDto1).length <= 0) {
      wx.showModal({
        title: '登录失败',
        content: '请退出应用后，重新进入！',
        confirmText: '确定',
        success: res => {
          wx.exitMiniProgram({
            success: function () {
              //推出小程序
            }
          })
        }
    })
      return false
    }

    if (userInfoDto1.roleCodeList.length === 0) {
      //游客角色
      this.setData({
        role: ''
      })
    } else if (userInfoDto1.roleCodeList.includes('role_audit')) {
      //审核管理员
      this.setData({
        role: '2'
      })
    } else if (userInfoDto1.roleCodeList.includes('role_verify')) {
      //信息核实
      this.setData({
        role: '1'
      })
    }else if (userInfoDto1.roleCodeList.includes('role_supervise') || userInfoDto1.roleCodeList.includes('role_biz') || userInfoDto1.roleCodeList.includes('role_safety') || userInfoDto1.roleCodeList.includes('role_charge_leader') || userInfoDto1.roleCodeList.includes('role_main_leader')) {
      //审核管理
      this.setData({
        role: '3'
      })
    }

  },
  toChild1(){
    wx.navigateTo({
      url: '/pages/monitoring/hiddentask/monitoringlist'
    })
  },
  toChild2(){
    wx.navigateTo({
      url: '/pages/monitoring/approval/approvaltask'
    })
  },
  toChild3(){
    wx.navigateTo({
      url: '/pages/monitoring/assignment/assignmentlist'
    })
  },
  toChild4(){
    wx.navigateTo({
      url: '/pages/monitoring/judge/judgelist'
    })
  },
})